using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MomentumV2
{
    class mMenuEntry
    {

        #region Instance Variables

        string m_Text;

        #endregion

        #region Properties

        public string Text
        {
            get { return m_Text; }
            set { m_Text = value; }
        }

        #endregion

        #region Events

        public event EventHandler<EventArgs> Selected;

        protected internal virtual void OnSelectEntry()
        {
            if (Selected != null)
            {
                Selected(this, EventArgs.Empty);
            }
        }

        #endregion

        #region Initialization

        /// <summary>
        /// Default constructor.
        /// </summary>
        public mMenuEntry()
        {
            m_Text = "";
        }

        /// <summary>
        /// Constructs a new menu entry with the specified text.
        /// </summary>
        public mMenuEntry(string text)
        {
            m_Text = text;
        }

        #endregion

        #region Draw

        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        public virtual void Draw(mMenuScreen screen, Vector2 position,
                                 bool isSelected, GameTime gameTime)
        {
            Color color = isSelected ? new Color(160, 140, 100) : Color.White;
            Color shadow = new Color(0, 0, 0, screen.TransitionAlpha);

            color = new Color(color.R, color.G, color.B, screen.TransitionAlpha);

            mScreenManager screenManager = screen.ScreenManager;
            SpriteBatch spriteBatch = screenManager.SpriteBatch;
            SpriteFont font = screenManager.SpriteFont;

            Vector2 origin = new Vector2(0, font.LineSpacing / 2);
            Vector2 offset = new Vector2(2, 2);

            spriteBatch.DrawString(font, m_Text, position + offset, shadow, 0,
                                   origin, 1, SpriteEffects.None, 0);
            spriteBatch.DrawString(font, m_Text, position, color, 0,
                                   origin, 1, SpriteEffects.None, 0);
        }


        /// <summary>
        /// Queries how much space this menu entry requires.
        /// </summary>
        public virtual int GetHeight(mMenuScreen screen)
        {
            return screen.ScreenManager.SpriteFont.LineSpacing;
        }

        #endregion

    }
}
